package com.andova.egl

import android.graphics.Color
import android.opengl.GLSurfaceView
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import javax.microedition.khronos.egl.EGLConfig
import javax.microedition.khronos.opengles.GL10

class ColorRenderActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val glsv = GLSurfaceView(this)
        setContentView(glsv)
        glsv.setRenderer(Render(Color.RED))
    }
}

class Render(private val color: Int) : GLSurfaceView.Renderer {
    private val egl = EGL()
    override fun onDrawFrame(gl: GL10?) = run { egl.drawFrame() }
    override fun onSurfaceCreated(gl: GL10?, config: EGLConfig?) = run { egl.surfCreated(color) }
    override fun onSurfaceChanged(gl: GL10?, width: Int, height: Int) = run { egl.surfChanged(width, height) }
}